
package org.ares.app.demo.services;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.ares.app.demo.daos.AuthService;
import org.ares.app.demo.daos.CarDao;
import org.ares.app.demo.daos.CaruserDao;
import org.ares.app.demo.daos.LoginDao;
import org.ares.app.demo.daos.ParamDao;
import org.ares.app.demo.daos.PeccancyDao;
import org.ares.app.demo.daos.PectypeDao;
import org.ares.app.demo.daos.UserDao;
import org.ares.app.demo.daos.sand.SandBusStationDao;
import org.ares.app.demo.daos.sand.SandCarBlackListDao;
import org.ares.app.demo.daos.sand.SandCarChangeDao;
import org.ares.app.demo.daos.sand.SandCarFeeDao;
import org.ares.app.demo.daos.sand.SandCarInfoDao;
import org.ares.app.demo.daos.sand.SandEtcTraLogDao;
import org.ares.app.demo.daos.sand.SandMonthTemperDao;
import org.ares.app.demo.daos.sand.SandOtherSingleDao;
import org.ares.app.demo.daos.sand.SandRoadLightDao;
import org.ares.app.demo.daos.sand.SandTransLightDao;
import org.ares.app.demo.daos.sand.SandTravelCarHistoryDao;
import org.ares.app.demo.daos.sand.SandTravelCommitOrderDao;
import org.ares.app.demo.daos.sand.SandTravelCustomizedBusDao;
import org.ares.app.demo.daos.sand.SandTravelFeedBackDao;
import org.ares.app.demo.daos.sand.SandTravelInfoDao;
import org.ares.app.demo.daos.sand.SandTravelMetroDao;
import org.ares.app.demo.daos.sand.SandTravelNewsDao;
import org.ares.app.demo.daos.sand.SandTravelNoticeDao;
import org.ares.app.demo.daos.sand.SandTravelOrderDao;
import org.ares.app.demo.daos.sand.SandTravelOrderItemDao;
import org.ares.app.demo.daos.sand.SandTravelParkDao;
import org.ares.app.demo.daos.sand.SandTravelRateDao;
import org.ares.app.demo.daos.sand.SandTravelSpotDao;
import org.ares.app.demo.daos.sand.SandTravelSuggestionDao;
import org.ares.app.demo.entities.Carinfo;
import org.ares.app.demo.entities.Caruser;
import org.ares.app.demo.entities.Peccancy;
import org.ares.app.demo.entities.Peccancytype;
import org.ares.app.demo.entities.SUser;
import org.ares.app.demo.entities.sand.Scarblacklist;
import org.ares.app.demo.entities.sand.Scarcharge;
import org.ares.app.demo.entities.sand.Scarfee;
import org.ares.app.demo.entities.sand.Scarinfo;
import org.ares.app.demo.entities.sand.Setctralog;
import org.ares.app.demo.entities.sand.Smonthtemperature;
import org.ares.app.demo.entities.sand.Sothersingle;
import org.ares.app.demo.entities.sand.Sroadlight;
import org.ares.app.demo.entities.sand.Stralight;
import org.ares.app.demo.entities.sand.Stravelcommitorder;
import org.ares.app.demo.entities.sand.Stravelfeedback;
import org.ares.app.demo.entities.sand.Stravelorder;
import org.ares.app.demo.entities.sand.Stravelrate;
import org.ares.app.demo.entities.sand.Stravelroute;
import org.ares.app.demo.entities.sand.Stravelspot;
import org.ares.app.demo.entities.sand.Stravelsuggestion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class SimuSandService {
    static final int[] PM25 = new int[]{0, 299};
    static final int[] CO2 = new int[]{15, 9995};
    static final int[] LIGHTINTENSITY = new int[]{1, 4092};
    static final int[] HUMIDITY = new int[]{20, 90};
    static final int[] TEMPERATURE = new int[]{0, 49};
    static final int[] DISTANCE = new int[]{0, 110850};
    static final int MIN_YELLOW_TIME = 3;
    static final int MAX_YELLOW_TIME = 5;
    final Logger log = LoggerFactory.getLogger(this.getClass());
    final SimpleDateFormat sdf_date_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    final SimpleDateFormat sdf_date = new SimpleDateFormat("yyyy-MM-dd");
    @Resource
    SandCarInfoDao sCarInfoDao;
    @Resource
    SandCarChangeDao sCarChargeDao;
    @Resource
    SandCarFeeDao sCarFeeDao;
    @Resource
    SandTransLightDao sTransLightDao;
    @Resource
    SandRoadLightDao sRoadLightDao;
    @Resource
    SandMonthTemperDao sMonthTemperDao;
    @Resource
    SandOtherSingleDao sOtherSingleDao;
    @Resource
    SandBusStationDao sBusStationDao;
    @Resource
    SandEtcTraLogDao sEtcTraLogDao;
    @Resource
    SandCarBlackListDao sCarBlackListDao;
    @Resource
    SandTravelInfoDao sTravelInfoDao;
    @Resource
    SandTravelSpotDao sTravelSpotDao;
    @Resource
    SandTravelOrderDao sTravelOrderDao;
    @Resource
    SandTravelNewsDao sTravelNewsDao;
    @Resource
    SandTravelNoticeDao sTravelNoticeDao;
    @Resource
    SandTravelSuggestionDao sTravelSuggestionDao;
    @Resource
    SandTravelFeedBackDao sTravelFeedBackDao;
    @Resource
    SandTravelCommitOrderDao sTravelCommitTorderDao;
    @Resource
    SandTravelRateDao sTravelRateDao;
    @Resource
    SandTravelMetroDao sTravelMetroDao;
    @Resource
    SandTravelCustomizedBusDao sTravelCustomizedBusDao;
    @Resource
    SandTravelOrderItemDao sTravelOrderItemDao;
    @Resource
    SandTravelCarHistoryDao sTravelCarHistoryDao;
    @Resource
    SandTravelParkDao sTravelParkMessageDao;
    @Resource
    UserDao userdao;
    @Resource
    ParamDao prmdao;
    @Resource
    AuthService auth;
    @Resource
    ParamDao paramdao;
    @Resource
    PeccancyDao peccancydao;
    @Resource
    CarDao cardao;
    @Resource
    CaruserDao caruserdao;
    @Resource
    LoginDao logindao;
    @Resource
    PectypeDao pecdao;
    @Value("${etc.auto.fee.enable}")
    boolean auto_fee;

    public SimuSandService() {
    }

    public void setCarAction(Integer carid, String action) {
        boolean var3 = "Start".equals(action) || "Stop".equals(action);
        if (!var3) {
            throw new RuntimeException("param value is invalid");
        } else {
            Scarinfo var4 = (Scarinfo)this.sCarInfoDao.findOne(carid);
            if (var4 == null) {
                throw new RuntimeException("not found this id");
            } else {
                var4.setCaraction(action);
                this.sCarInfoDao.save(var4);
            }
        }
    }

    public String getCarAction(Integer carid) {
        Scarinfo var2 = (Scarinfo)this.sCarInfoDao.findOne(carid);
        if (var2 == null) {
            throw new RuntimeException("not found this id");
        } else {
            return var2.getCaraction();
        }
    }

    public Integer getCarAccountBalance(Integer carid) {
        Scarinfo var2 = (Scarinfo)this.sCarInfoDao.findOne(carid);
        if (var2 == null) {
            throw new RuntimeException("not found this id");
        } else {
            return var2.getBalance();
        }
    }

    public void setCarAccountRecharge(Integer carid, Integer money) {
        Scarinfo var3 = (Scarinfo)this.sCarInfoDao.findOne(carid);
        if (var3 == null) {
            throw new RuntimeException("not found this id");
        } else if (money <= 0) {
            throw new RuntimeException("param money must be greater then 0");
        } else {
            var3.setBalance(var3.getBalance() + money);
            this.sCarInfoDao.save(var3);
            Scarcharge var4 = new Scarcharge();
            var4.setChargetime(new Date());
            var4.setMoney(money);
            var4.setScarinfo(var3);
            this.sCarChargeDao.save(var4);
        }
    }

    public List<Map<String, Object>> getCarAccountRecord(Integer carid) {
        ArrayList var2 = new ArrayList();
        ((Scarinfo)this.sCarInfoDao.getOne(carid)).getScarcharges().stream().forEach((e) -> {
            HashMap var3 = new HashMap();
            var3.put("CarId", e.getScarinfo().getCarid());
            var3.put("Cost", e.getMoney());
            var3.put("Time", this.sdf_date_time.format(e.getChargetime()));
            var2.add(var3);
        });
        return var2;
    }

    public void setCarAccountFee(Integer carid, Integer money) {
        Scarinfo var3 = (Scarinfo)this.sCarInfoDao.findOne(carid);
        if (var3 == null) {
            throw new RuntimeException("not found this id");
        } else if (money <= 0) {
            throw new RuntimeException("param money must be greater then 0");
        } else if (var3.getBalance() < money) {
            throw new RuntimeException("not sufficlent funds");
        } else {
            var3.setBalance(var3.getBalance() - money);
            this.sCarInfoDao.save(var3);
            Scarfee var4 = new Scarfee();
            var4.setFeetime(new Date());
            var4.setMoney(money);
            var4.setScarinfo(var3);
            this.sCarFeeDao.save(var4);
        }
    }

    public List<Map<String, Object>> getCarAccountFee(Integer carid) {
        ArrayList var2 = new ArrayList();
        ((Scarinfo)this.sCarInfoDao.getOne(carid)).getScarfees().stream().forEach((e) -> {
            HashMap var3 = new HashMap();
            var3.put("CarId", e.getScarinfo().getCarid());
            var3.put("Cost", e.getMoney());
            var3.put("Time", this.sdf_date_time.format(e.getFeetime()));
            var2.add(var3);
        });
        return var2;
    }

    public void setTrafficLightNowStatus(Integer traLightid, String status, Integer time) {
        boolean var4 = "Red".equals(status) || "Green".equals(status) || "Yellow".equals(status);
        if (!var4) {
            throw new RuntimeException("param value is invalid");
        } else {
            Stralight var5 = (Stralight)this.sTransLightDao.findOne(traLightid);
            if (var5 == null) {
                throw new RuntimeException("not found this id");
            } else {
                var5.setStatus(status);
                var5.setTime(time);
                this.sTransLightDao.save(var5);
            }
        }
    }

    public Map<String, Object> getTrafficLightNowStatus(Integer traLightid) {
        HashMap var2 = new HashMap();
        Stralight var3 = (Stralight)this.sTransLightDao.findOne(traLightid);
        if (var3 == null) {
            throw new RuntimeException("not found this id");
        } else {
            var2.put("Status", var3.getStatus());
            var2.put("Time", var3.getTime());
            return var2;
        }
    }

    public void setTrafficLightConfig(Integer traLightid, int redtime, int greentime, int yellowtime) {
        boolean var5 = yellowtime >= 3 && yellowtime <= 5;
        if (!var5) {
            throw new RuntimeException("param value is invalid");
        } else {
            Stralight var6 = (Stralight)this.sTransLightDao.findOne(traLightid);
            if (var6 == null) {
                throw new RuntimeException("not found this id");
            } else {
                var6.setGreentime(greentime);
                var6.setRedtime(redtime);
                var6.setYellowtime(yellowtime);
                this.sTransLightDao.save(var6);
            }
        }
    }

    public Map<String, Object> getTrafficLightConfigAction(Integer traLightid) {
        HashMap var2 = new HashMap();
        Stralight var3 = (Stralight)this.sTransLightDao.findOne(traLightid);
        var2.put("RedTime", var3.getRedtime());
        var2.put("GreenTime", var3.getGreentime());
        var2.put("YellowTime", var3.getYellowtime());
        return var2;
    }

    public void setRoadLightStatusAction(Integer roadlightid, String action) {
        boolean var3 = "Close".equals(action) || "Open".equals(action);
        if (!var3) {
            throw new RuntimeException("param value is invalid");
        } else {
            Sroadlight var4 = (Sroadlight)this.sRoadLightDao.findOne(roadlightid);
            if (var4 == null) {
                throw new RuntimeException("not found this id");
            } else {
                var4.setStatus(action);
                this.sRoadLightDao.save(var4);
            }
        }
    }

    public String getRoadLightStatus(Integer roadlightid) {
        Sroadlight var2 = (Sroadlight)this.sRoadLightDao.findOne(roadlightid);
        if (var2 == null) {
            throw new RuntimeException("not found this id");
        } else {
            return var2.getStatus();
        }
    }

    public void setLightSenseValve(int down, int up) {
        Sothersingle var3 = (Sothersingle)this.sOtherSingleDao.findOne("Down");
        var3.setValue(down + "");
        Sothersingle var4 = (Sothersingle)this.sOtherSingleDao.findOne("Up");
        var4.setValue(up + "");
        this.sOtherSingleDao.save(var3);
        this.sOtherSingleDao.save(var4);
    }

    public void setRoadLightControlMode(String cmValue) {
        boolean var2 = "Auto".equals(cmValue) || "Manual".equals(cmValue);
        if (!var2) {
            throw new RuntimeException("param value is invalid");
        } else {
            Sothersingle var3 = (Sothersingle)this.sOtherSingleDao.findOne("ControlMode");
            var3.setValue(cmValue);
            this.sOtherSingleDao.save(var3);
        }
    }

    public String getRoadLightControlMode() {
        Sothersingle var1 = (Sothersingle)this.sOtherSingleDao.findOne("ControlMode");
        return var1.getValue();
    }

    public Map<String, Object> getLightSenseValve() {
        HashMap var1 = new HashMap();
        Sothersingle var2 = (Sothersingle)this.sOtherSingleDao.findOne("Down");
        Sothersingle var3 = (Sothersingle)this.sOtherSingleDao.findOne("Up");
        var1.put("lower", Integer.parseInt(var2.getValue()));
        var1.put("upper", Integer.parseInt(var3.getValue()));
        return var1;
    }

    public List<Map<String, Object>> getEtcTtrafficLog() {
        ArrayList var1 = new ArrayList();
        this.sEtcTraLogDao.findAll().stream().forEach((e) -> {
            LinkedHashMap var3 = new LinkedHashMap();
            var3.put("carid", e.getCarid());
            var3.put("intime", this.sdf_date_time.format(e.getIntime()));
            var3.put("outtime", this.sdf_date_time.format(e.getOuttime()));
            var3.put("money", e.getMoney());
            var1.add(var3);
        });
        return var1;
    }

    public List<Map<String, Object>> getEtcBlacklist(String username) {
        ArrayList var2 = new ArrayList();
        this.sCarBlackListDao.findAll().stream().filter((e) -> {
            return username.equals(e.getUsername());
        }).forEach((e) -> {
            LinkedHashMap var3 = new LinkedHashMap();
            var3.put("carid", e.getCarid());
            var3.put("datetime", this.sdf_date_time.format(e.getDatetime()));
            var2.add(var3);
        });
        return var2;
    }

    public List<Map<String, Object>> getTravelInfo(String id) {
        ArrayList var2 = new ArrayList();
        if (id.equals("0")) {
            this.sTravelInfoDao.findAll().stream().forEach((e) -> {
                LinkedHashMap var2x = new LinkedHashMap();
                var2x.put("name", e.getName());
                var2x.put("price", e.getPrice());
                var2x.put("map", e.getMap());
                List var3 = e.getStravelspot();
                ArrayList var4 = new ArrayList();
                ArrayList var5 = new ArrayList();
                Iterator var6 = var3.iterator();

                while(var6.hasNext()) {
                    Stravelspot var7 = (Stravelspot)var6.next();
                    LinkedHashMap var8 = new LinkedHashMap();
                    var8.put("spotname", var7.getSpotname());
                    var8.put("opentime", var7.getOpentime());
                    var8.put("closename", var7.getClosetime());
                    var5.add(var7.getSpotname());
                    var4.add(var8);
                }

                var2x.put("spots", var5);
                var2x.put("time", var4);
                var2x.put("intro", e.getIntro());
                var2.add(var2x);
            });
        } else {
            this.sTravelInfoDao.findAll().stream().filter((e) -> {
                return id.equals(String.valueOf(e.getLineid()));
            }).forEach((e) -> {
                LinkedHashMap var2x = new LinkedHashMap();
                var2x.put("name", e.getName());
                var2x.put("price", e.getPrice());
                var2x.put("map", e.getMap());
                List var3 = e.getStravelspot();
                ArrayList var4 = new ArrayList();
                ArrayList var5 = new ArrayList();
                Iterator var6 = var3.iterator();

                while(var6.hasNext()) {
                    Stravelspot var7 = (Stravelspot)var6.next();
                    LinkedHashMap var8 = new LinkedHashMap();
                    var8.put("spotname", var7.getSpotname());
                    var8.put("opentime", var7.getOpentime());
                    var8.put("closename", var7.getClosetime());
                    var5.add(var7.getSpotname());
                    var4.add(var8);
                }

                var2x.put("spots", var5);
                var2x.put("time", var4);
                var2x.put("intro", e.getIntro());
                var2.add(var2x);
            });
        }

        return var2;
    }

    public List<Map<String, Object>> getTravelMetro() {
        ArrayList var1 = new ArrayList();
        this.sTravelMetroDao.findAll().stream().forEach((e) -> {
            LinkedHashMap var2 = new LinkedHashMap();
            var2.put("id", e.getRid());
            var2.put("metro_code", e.getMetro_code());
            var2.put("start_place", e.getStart_place());
            var2.put("end_place", e.getEnd_place());
            var2.put("img", e.getImg());
            var2.put("Start_place_start_time", e.getStart_place_start_time());
            var2.put("Start_place_end_time", e.getStart_place_end_time());
            var2.put("End_place_start_time", e.getEnd_place_start_time());
            var2.put("End_place_end_time", e.getEnd_place_end_time());
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, Object>> getTravelAllInfo() {
        ArrayList var1 = new ArrayList();
        List var2 = this.query_trafficlight_info();
        List var3 = this.query_roadlight_info();
        List var4 = this.query_sand_car_info();
        HashMap var5 = new HashMap();
        var5.put("signalinfo", var2);
        var5.put("carinfo", var4);
        var5.put("lightinfo", var3);
        var5.put("controlmode", this.getRoadLightControlMode());
        var5.put("upper", this.getLightSenseValve().get("upper"));
        var5.put("lower", this.getLightSenseValve().get("lower"));
        var5.put("lightintensity", this.getAllSense().get("LightIntensity"));
        var1.add(var5);
        return var1;
    }

    public void setTravelOrder(Map<String, String> map) {
        Stravelorder var2 = new Stravelorder();
        var2.setEndSpot((String)map.get("EndSpot"));
        var2.setPhoneNumber((String)map.get("PhoneNumber"));
        var2.setStartSpot((String)map.get("StartSpot"));
        var2.setTid(Integer.valueOf((String)map.get("Tid")));
        var2.setTravelDate((String)map.get("TravelDate"));
        var2.setUser((String)map.get("User"));
        var2.setUserName((String)map.get("UserName"));
        var2.setFlag(0);
        this.sTravelOrderDao.save(var2);
    }

    public void setCommitOrder(Map<String, String> map) {
        Stravelcommitorder var2 = new Stravelcommitorder();
        var2.setBus_id(Integer.valueOf((String)map.get("bus_id")));
        var2.setUserName((String)map.get("UserName"));
        var2.setUser((String)map.get("User"));
        var2.setPhone_number((String)map.get("phone_number"));
        var2.setBusstop_start((String)map.get("busstop_start"));
        var2.setBusstop_end((String)map.get("busstop_end"));
        var2.setBusstop_date((String)map.get("busstop_date"));
        this.sTravelCommitTorderDao.save(var2);
    }

    public List<Map<String, Object>> gettTravelOrder(String username) {
        ArrayList var2 = new ArrayList();
        this.sTravelOrderDao.findAll().stream().filter((e) -> {
            return username.equals(e.getUserName());
        }).forEach((e) -> {
            LinkedHashMap var2x = new LinkedHashMap();
            var2x.put("Tid", e.getTid());
            var2x.put("User", e.getUser());
            var2x.put("UserName", e.getUserName());
            var2x.put("EndSpot", e.getEndSpot());
            var2x.put("PhoneNumber", e.getPhoneNumber());
            var2x.put("StartSpot", e.getStartSpot());
            var2x.put("TravelDate", e.getTravelDate());
            var2x.put("Flag", e.getFlag());
            var2.add(var2x);
        });
        return var2;
    }

    public List<Map<String, Object>> getCustomizedBus() {
        ArrayList var1 = new ArrayList();
        this.sTravelCustomizedBusDao.findAll().stream().forEach((e) -> {
            HashMap var2 = new HashMap();
            var2.put("id", e.getId());
            var2.put("busline_name", e.getBusline_name());
            var2.put("start_place", e.getStart_place());
            var2.put("end_place", e.getEnd_place());
            var2.put("start_place_start_time", e.getStart_place_start_time());
            var2.put("start_place_end_time", e.getStart_place_end_time());
            var2.put("end_place_start_time", e.getEnd_place_start_time());
            var2.put("end_place_end_time", e.getEnd_place_end_time());
            var2.put("busstop_code_map_url", e.getBusstop_code_map_url());
            var2.put("price", e.getPrice());
            List var3 = e.getStravelroute();
            ArrayList var4 = new ArrayList();
            Iterator var5 = var3.iterator();

            while(var5.hasNext()) {
                Stravelroute var6 = (Stravelroute)var5.next();
                var4.add(var6.getName());
            }

            var2.put("route", var4);
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, Object>> getOrderItem(String username) {
        ArrayList var2 = new ArrayList();
        this.sTravelCommitTorderDao.findAll().stream().filter((e) -> {
            return username.equals(e.getUserName());
        }).forEach((e) -> {
            LinkedHashMap var2x = new LinkedHashMap();
            var2x.put("UserName", e.getUserName());
            var2x.put("user", e.getUser());
            var2x.put("phone_number", e.getPhone_number());
            var2x.put("bus_id", e.getBus_id());
            var2x.put("busstop_date", e.getBusstop_date());
            var2x.put("busstop_start", e.getBusstop_start());
            var2x.put("busstop_end", e.getBusstop_end());
            var2x.put("flag", e.getFlag());
            var2.add(var2x);
        });
        return var2;
    }

    public List<Map<String, Object>> carHistory(Map<String, String> map) {
        ArrayList var2 = new ArrayList();
        this.sTravelCarHistoryDao.findAll().stream().forEach((e) -> {
            LinkedHashMap var2x = new LinkedHashMap();
            var2x.put("id", e.getId());
            var2x.put("car_code", e.getCar_code());
            var2x.put("car_number", e.getCar_number());
            var2x.put("car_in_time", e.getCar_in_time());
            var2x.put("car_out_time", e.getCar_out_time());
            var2x.put("car_consumption_money", e.getCar_consumption_money());
            var2.add(var2x);
        });
        return var2;
    }

    public List<Map<String, Object>> getpark() {
        ArrayList var1 = new ArrayList();
        this.sTravelParkMessageDao.findAll().stream().forEach((e) -> {
            LinkedHashMap var2 = new LinkedHashMap();
            var2.put("id", e.getId());
            var2.put("parking_name", e.getParking_name());
            var2.put("coordinate_longitude", e.getCoordinate_longitude());
            var2.put("coordinate_latitude", e.getCoordinate_latitude());
            var2.put("distance", e.getDistance());
            var2.put("total_parking_number", e.getTotal_parking_number());
            var2.put("free_parking_number", e.getFree_parking_number());
            var2.put("payment_method", e.getPayment_method());
            var2.put("parking_lot_address", e.getParking_lot_address());
            var2.put("open_type", e.getOpen_type());
            var2.put("charging_reference", e.getCharging_reference());
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, Object>> getTravelNews(int Category) {
        ArrayList var2 = new ArrayList();
        if (Category == 0) {
            this.sTravelNewsDao.findAll().stream().forEach((e) -> {
                HashMap var2x = new HashMap();
                var2x.put("id", e.getId());
                var2x.put("category", e.getCategory());
                var2x.put("title", e.getTitle());
                var2x.put("content", e.getContent());
                var2x.put("publishtime", e.getPublishtime());
                var2.add(var2x);
            });
        } else {
            this.sTravelNewsDao.findAll().stream().filter((e) -> {
                return Category == e.getCategory();
            }).forEach((e) -> {
                HashMap var2x = new HashMap();
                var2x.put("id", e.getId());
                var2x.put("category", e.getCategory());
                var2x.put("title", e.getTitle());
                var2x.put("content", e.getContent());
                var2x.put("publishtime", e.getPublishtime());
                var2.add(var2x);
            });
        }

        return var2;
    }

    public List<Map<String, Object>> getTravelNotice() {
        ArrayList var1 = new ArrayList();
        this.sTravelNoticeDao.findAll().stream().forEach((e) -> {
            HashMap var2 = new HashMap();
            var2.put("id", e.getId());
            var2.put("title", e.getTitle());
            var2.put("content", e.getContent());
            var2.put("publishTime", e.getPublishTime());
            var1.add(var2);
        });
        return var1;
    }

    public void setTravelSuggestion(Map<String, String> map) {
        Stravelsuggestion var2 = new Stravelsuggestion();
        Date var3 = new Date();
        var2.setUserName((String)map.get("UserName"));
        var2.setTitle((String)map.get("title"));
        var2.setContent((String)map.get("content"));
        var2.setPhoneNumber((String)map.get("phone_number"));
        var2.setSubmitTime(this.sdf_date_time.format(var3));
        var2.setFlag(0);
        this.sTravelSuggestionDao.save(var2);
    }

    public void setFeedBack(Map<String, String> map) {
        Stravelfeedback var2 = new Stravelfeedback();
        var2.setTitlename((String)map.get("titleName"));
        var2.setOpinioncontent((String)map.get("opinionContent"));
        var2.setTelephonenumber((String)map.get("telephoneNumber"));
        var2.setUsername((String)map.get("UserName"));
        this.sTravelFeedBackDao.save(var2);
    }

    public void setRate(Map<String, String> map) {
        Stravelrate var2 = new Stravelrate();
        var2.setPayment_method((String)map.get("payment_method"));
        var2.setRate_sum((String)map.get("rate_sum"));
        var2.setUserName((String)map.get("UserName"));
        this.sTravelRateDao.save(var2);
    }

    public List<Map<String, Object>> getTravelSuggestion(String UserName) {
        ArrayList var2 = new ArrayList();
        this.sTravelSuggestionDao.findAll().stream().filter((e) -> {
            return UserName.equals(e.getUserName());
        }).forEach((e) -> {
            HashMap var2x = new HashMap();
            var2x.put("UserName", e.getUserName());
            var2x.put("Title", e.getTitle());
            var2x.put("Content", e.getContent());
            var2x.put("PhoneNumber", e.getPhoneNumber());
            var2x.put("SubmitTime", e.getSubmitTime());
            var2x.put("ReplyTime", e.getReplyTime());
            var2x.put("ReplyContent", e.getReplyContent());
            var2x.put("Flag", e.getFlag());
            var2.add(var2x);
        });
        return var2;
    }

    public void setEtcBlacklist(List<Map<String, String>> list, String username) {
        this.sCarBlackListDao.deleteByUsername(username);

        Scarblacklist var5;
        for(Iterator var3 = list.iterator(); var3.hasNext(); this.sCarBlackListDao.save(var5)) {
            Map var4 = (Map)var3.next();
            var5 = new Scarblacklist();
            var5.setCarid(Integer.parseInt((String)var4.get("carid")));
            var5.setUsername(username);

            try {
                var5.setDatetime(this.sdf_date_time.parse((String)var4.get("datetime")));
            } catch (ParseException var7) {
                throw new RuntimeException("datetime format is invalid");
            }
        }

    }

    public void setEtcRate(int rate) {
        Sothersingle var2 = (Sothersingle)this.sOtherSingleDao.findOne("FeeRate");
        var2.setValue(rate + "");
        this.sOtherSingleDao.save(var2);
    }

    public int getEtcRate() {
        Sothersingle var1 = (Sothersingle)this.sOtherSingleDao.findOne("FeeRate");
        return Integer.parseInt(var1.getValue());
    }

    public int getRoadStatus(int roadid) {
        return this.randomOfRange(1, 5);
    }

    public int getBusCapacity(int busid) {
        return this.randomOfRange(30, 100);
    }

    public List<Map<String, Object>> getBusStationInfoFromDB(int busstationid) {
        ArrayList var2 = new ArrayList();
        this.sBusStationDao.findByBusstationid(busstationid).stream().forEach((e) -> {
            HashMap var2x = new HashMap();
            var2x.put("Distance", e.getDistance());
            var2x.put("BusId", e.getBusid());
            var2.add(var2x);
        });
        return var2;
    }

    public List<Map<String, Object>> getBusStationInfo(int busstationid, int buscount) {
        ArrayList var3 = new ArrayList();

        for(int var4 = 1; var4 <= buscount; ++var4) {
            HashMap var5 = new HashMap();
            var5.put("Distance", this.randomOfRange(DISTANCE[0], DISTANCE[1]));
            var5.put("BusId", var4);
            var3.add(var5);
        }

        return var3;
    }

    public Map<String, Object> getWeather() {
        HashMap var1 = new HashMap();
        var1.put("WCurrent", this.getTemperOfToday());
        byte var2 = 6;
        ArrayList var3 = new ArrayList();
        this.getTemperRangeOfAfterToday(var2).stream().forEach((e) -> {
            HashMap var2a = new HashMap();
            var2a.put("WData", e[0]);
            var2a.put("temperature", e[1]);
            var3.add(var2a);
        });
        var1.put("ROWS_DETAIL", var3);
        return var1;
    }

    int randomOfRange(int start, int end) {
        if (start > end) {
            int var3 = end;
            end = start;
            start = var3;
        }

        return (int)(Math.random() * (double)(end - start + 1) + (double)start);
    }

    int[] getTempeRangeByMonth(int month) {
        if (month <= 12 && month >= 1) {
            Smonthtemperature var2 = (Smonthtemperature)this.sMonthTemperDao.getOne(month);
            return new int[]{var2.getMint(), var2.getMaxt()};
        } else {
            throw new RuntimeException("Month is invalid");
        }
    }

    int getTemperOfMonthDay(int month, int day) {
        if (month <= 12 && month >= 1 && day >= 1 && day <= 31) {
            int[] var3 = this.getTempeRangeByMonth(month);
            int var4 = var3[0];
            int var5 = var3[1];
            boolean var6 = false;
            int var7 = this.randomOfRange(var4, var5);
            if (var7 > var4) {
                var7 = var4;
            }

            System.out.println("start" + var4 + "end" + var5 + "TemperOfToday" + var7);
            return var7;
        } else {
            throw new RuntimeException("Month or Day is invalid");
        }
    }

    int getTemperOfToday() {
        LocalDate var1 = LocalDate.now();
        int var2 = var1.getMonthValue();
        int var3 = var1.getDayOfMonth();
        return this.getTemperOfMonthDay(var2, var3);
    }

    int[] getTemperRangeOfToday() {
        int[] var1 = new int[2];
        int var2 = this.getTemperOfToday();
        int var3 = var2 + this.randomOfRange(3, 8);
        var1[0] = var2;
        var1[1] = var3;
        return var1;
    }

    List<String[]> getTemperRangeOfAfterToday(int days) {
        ArrayList var2 = new ArrayList();
        int var3 = this.getTemperOfToday();
        LocalDate var4 = LocalDate.now();

        for(int var5 = 0; var5 < days; ++var5) {
            String[] var6 = new String[2];
            int var7 = var3 + this.randomOfRange(-1, 1);
            int var8 = var7 + this.randomOfRange(3, 8);
            if (var5 != 0) {
                var4 = var4.plusDays(1L);
            }

            var6[0] = var4 + "";
            var6[1] = var7 + "~" + var8;
            var2.add(var6);
        }

        return var2;
    }

    public Map<String, Object> getAllSense() {
        HashMap var1 = new HashMap();
        var1.put("pm2.5", this.randomOfRange(PM25[0], PM25[1]));
        var1.put("co2", this.randomOfRange(CO2[0], CO2[1]));
        var1.put("temperature", this.getTemperOfToday());
        var1.put("humidity", this.randomOfRange(HUMIDITY[0], HUMIDITY[1]));
        var1.put("LightIntensity", this.randomOfRange(LIGHTINTENSITY[0], LIGHTINTENSITY[1]));
        return var1;
    }

    public Object getSenseByName(String key) {
        Object var2 = this.getAllSense().get(key);
        if (var2 == null) {
            throw new RuntimeException("param value is invalid");
        } else {
            return var2;
        }
    }

    @Scheduled(
            cron = "${etc.auto.fee.frequency}"
    )
    public void etcAutoFee() {
        if (this.auto_fee) {
            int var1 = this.getEtcRate();
            this.sCarInfoDao.findAll().forEach((e) -> {
                try {
                    this.setCarAccountFee(e.getCarid(), var1);
                    this.log.debug("[" + e.getCarid() + "] fee:" + var1);
                } catch (Exception var4) {
                    ;
                }

            });
        }
    }

    public List<Carinfo> query_car_info() {
        return this.cardao.findAll();
    }

    public List<Map<String, String>> get_car_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carnumber", "number", "pcardid", "carbrand", "buydate"};
        String[] var3 = new String[]{"车牌号", "车辆编号", "用户标识", "品牌", "购买日期"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, Object>> query_car_account_record() {
        ArrayList var1 = new ArrayList();
        this.sCarInfoDao.findAll().stream().forEach((c) -> {
            c.getScarcharges().stream().forEach((e) -> {
                HashMap var3 = new HashMap();
                var3.put("carid", e.getScarinfo().getCarid());
                var3.put("cost", e.getMoney());
                var3.put("time", this.sdf_date_time.format(e.getChargetime()));
                var1.add(var3);
            });
        });
        return var1;
    }

    public List<Map<String, String>> get_car_account_record_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carid", "cost", "time"};
        String[] var3 = new String[]{"车辆编号", "充值金额", "充值时间"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, Object>> query_car_account_fee() {
        ArrayList var1 = new ArrayList();
        this.sCarInfoDao.findAll().stream().forEach((c) -> {
            c.getScarfees().stream().forEach((e) -> {
                HashMap var3 = new HashMap();
                var3.put("carid", e.getScarinfo().getCarid());
                var3.put("cost", e.getMoney());
                var3.put("time", this.sdf_date_time.format(e.getFeetime()));
                var1.add(var3);
            });
        });
        return var1;
    }

    public List<Map<String, String>> get_car_account_fee_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carid", "cost", "time"};
        String[] var3 = new String[]{"车辆编号", "扣费金额", "扣费时间"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Peccancy> query_car_peccancy() {
        System.out.println(this.peccancydao.findAll().toString());
        return this.peccancydao.findAll();
    }

    public List<Map<String, String>> get_car_peccancy_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carnumber", "pcode", "paddr", "pdatetime"};
        String[] var3 = new String[]{"车牌号", "违章号", "违章地址", "违章时间"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_sand_car_info() {
        ArrayList var1 = new ArrayList();
        this.sCarInfoDao.findAll().stream().forEach((e) -> {
            HashMap var2 = new HashMap();
            var2.put("carid", e.getCarid());
            var2.put("caraction", e.getCaraction());
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, String>> get_sand_car_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carid", "caraction", "balance"};
        String[] var3 = new String[]{"车辆编号", "行驶状态", "余额"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Peccancytype> query_peccancy_type() {
        return this.pecdao.findAll();
    }

    public List<Map<String, String>> get_peccancy_type_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"pcode", "pmoney", "pscore", "premarks"};
        String[] var3 = new String[]{"违章代码", "金额", "扣除分数", "代码含义"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<SUser> query_user_info() {
        return this.userdao.findAll();
    }

    public List<Setctralog> query_etc_traffic_log() {
        return this.sEtcTraLogDao.findAll();
    }

    public List<Map<String, String>> get_etc_traffic_log_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carid", "intime", "outtime", "money"};
        String[] var3 = new String[]{"车辆编号", "驶入时间", "离开时间", "应付金额"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Caruser> query_car_user_info() {
        return this.caruserdao.findAll();
    }

    public List<Map<String, String>> get_car_user_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"username", "pname", "pcardid", "psex", "ptel", "pregisterdate"};
        String[] var3 = new String[]{"系统用户名称", "用户姓名", "身份证号", "性别", "电话", "注册时间"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, Object>> query_station_info(int station_count, int bus_count) {
        ArrayList var3 = new ArrayList();

        for(int var4 = 1; var4 <= station_count; ++var4) {
            for(int var5 = 1; var5 <= bus_count; ++var5) {
                HashMap var6 = new HashMap();
                var6.put("distance", this.randomOfRange(DISTANCE[0], DISTANCE[1]));
                var6.put("busid", var5);
                var6.put("stationid", var4);
                var3.add(var6);
            }
        }

        return var3;
    }

    public List<Map<String, String>> get_station_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"stationid", "busid", "distance"};
        String[] var3 = new String[]{"站台编号", "公交车辆编号", "公交站台距离"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, Object>> query_bus_capacity(int bus_count) {
        ArrayList var2 = new ArrayList();

        for(int var3 = 1; var3 <= bus_count; ++var3) {
            HashMap var4 = new HashMap();
            var4.put("busid", var3);
            var4.put("capacity", this.randomOfRange(30, 100));
            var2.add(var4);
        }

        return var2;
    }

    public List<Map<String, String>> get_bus_capacity_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"busid", "capacity"};
        String[] var3 = new String[]{"公交车辆编号", "车载人数"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, Object>> query_etc_blacklist() {
        ArrayList var1 = new ArrayList();
        this.sCarBlackListDao.findAll().stream().forEach((e) -> {
            HashMap var3 = new HashMap();
            var3.put("carid", e.getCarid());
            var3.put("datetime", this.sdf_date_time.format(e.getDatetime()));
            var3.put("username", e.getUsername());
            var1.add(var3);
        });
        return var1;
    }

    public List<Map<String, String>> get_etc_blacklist_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"carid", "datetime", "username"};
        String[] var3 = new String[]{"黑名单车辆编号", "下发时间", "下发者"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_trafficlight_info() {
        ArrayList var1 = new ArrayList();
        this.sTransLightDao.findAll().stream().forEach((e) -> {
            HashMap var2 = new HashMap();
            var2.put("traflid", e.getTrafficlightid());
            var2.put("redtime", e.getRedtime());
            var2.put("greentime", e.getGreentime());
            var2.put("yellowtime", e.getYellowtime());
            var2.put("status", e.getStatus());
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, String>> get_trafficlight_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"traflid", "redtime", "greentime", "yellowtime", "status"};
        String[] var3 = new String[]{"红绿灯编号", "红灯时长", "绿灯时长", "黄灯时长", "当前状态"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_roadlight_info() {
        ArrayList var1 = new ArrayList();
        this.sRoadLightDao.findAll().stream().forEach((e) -> {
            HashMap var2 = new HashMap();
            var2.put("roadlightid", e.getRoadlightid());
            var2.put("ctlmode", e.getControlmode());
            var2.put("status", e.getStatus());
            var1.add(var2);
        });
        return var1;
    }

    public List<Map<String, String>> get_roadlight_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"roadlgid", "ctlmode", "status"};
        String[] var3 = new String[]{"路灯编号", "模式", "状态"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_road_info(int count) {
        ArrayList var2 = new ArrayList();

        for(int var3 = 1; var3 <= count; ++var3) {
            HashMap var4 = new HashMap();
            var4.put("roadid", var3);
            var4.put("status", this.randomOfRange(1, 5));
            var2.add(var4);
        }

        return var2;
    }

    public List<Map<String, String>> get_road_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"roadid", "status"};
        String[] var3 = new String[]{"道路编号", "拥挤程度"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_weather_info(int count) {
        ArrayList var2 = new ArrayList();
        HashMap var3 = new HashMap();
        var3.put("temperature", this.getTemperOfToday());
        var3.put("date", this.sdf_date.format(new Date()));
        var2.add(var3);
        this.getTemperRangeOfAfterToday(count).stream().forEach((e) -> {
            LinkedHashMap var3a = new LinkedHashMap();
            var3a.put("date", e[0]);
            var3a.put("temperature", e[1]);
            var2.add(var3a);
            this.log.debug("" + var3a);
        });
        return var2;
    }

    public List<Map<String, String>> get_weather_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"date", "temperature"};
        String[] var3 = new String[]{"日期", "温度"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }

    public List<Map<String, ?>> query_all_sense_info() {
        ArrayList var1 = new ArrayList();
        HashMap var2 = new HashMap();
        var2.put("sensename", "pm2.5");
        var2.put("value", this.randomOfRange(PM25[0], PM25[1]));
        var1.add(var2);
        HashMap var3 = new HashMap();
        var3.put("sensename", "co2");
        var3.put("value", this.randomOfRange(CO2[0], CO2[1]));
        var1.add(var3);
        HashMap var4 = new HashMap();
        var4.put("sensename", "temperature");
        var4.put("value", this.getTemperOfToday());
        var1.add(var4);
        HashMap var5 = new HashMap();
        var5.put("sensename", "humidity");
        var5.put("value", this.randomOfRange(HUMIDITY[0], HUMIDITY[1]));
        var1.add(var5);
        HashMap var6 = new HashMap();
        var6.put("sensename", "LightIntensity");
        var6.put("value", this.randomOfRange(LIGHTINTENSITY[0], LIGHTINTENSITY[1]));
        var1.add(var6);
        return var1;
    }

    public List<Map<String, String>> get_all_sense_info_head() {
        ArrayList var1 = new ArrayList();
        String[] var2 = new String[]{"sensename", "value"};
        String[] var3 = new String[]{"传感器", "测量结果"};

        for(int var4 = 0; var4 < var2.length; ++var4) {
            LinkedHashMap var5 = new LinkedHashMap();
            var5.put("column_name", var2[var4]);
            var5.put("column_title", var3[var4]);
            var1.add(var5);
        }

        return var1;
    }
}
